{{>licenseInfo}}

{{#imports}}
import { {{classname}} } from '../{{filename}}';
{{/imports}}
import { BaseApi } from './base.api';
import { throwIfNotDefined } from '../../../assert';
import { buildCollectionParam } from '../../../alfrescoApiClient';

{{#operations}}/**
* {{baseName}} service.
* @module {{#invokerPackage}}{{&invokerPackage}}/{{/invokerPackage}}{{#apiPackage}}{{&apiPackage}}/{{/apiPackage}}{{classname}}
*/
export class {{classname}} extends BaseApi {
    {{#operation}}/**
    * {{&summary}}
    * {{&description}}
    * {{&notes}}
    * {{#allParams}}{{#required}}
    * @param{{&vendorExtensions.x-jsdoc-type}} {{paramName}} {{&description}}{{/required}}{{/allParams}}{{#hasOptionalParams}}
    * @param opts Optional parameters{{#allParams}}{{^required}}
    * @param{{&vendorExtensions.x-jsdoc-type}} opts.{{paramName}} {{&description}}{{#defaultValue}} (default to {{.}}){{/defaultValue}}{{/required}}{{/allParams}}{{/hasOptionalParams}}
    * @return Promise<{{#returnType}}{{&returnType}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}{}{{/returnType}}>
    */
    {{nickname}}({{&vendorExtensions.x-codegen-argList}}) : Promise<{{#returnType}}{{&returnType}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}{{#canReturnError}} | {{&canReturnError}}{{/canReturnError}}> {
{{#allParams}}{{#required}}
        throwIfNotDefined({{paramName}}, '{{paramName}}');{{/required}}{{/allParams}}

        {{#hasOptionalParams}}opts = opts || {};{{/hasOptionalParams}}
        const postBody{{^bodyParam}}: null{{/bodyParam}} = {{#bodyParam}}{{#required}}{{paramName}}{{/required}}{{^required}}opts['{{paramName}}']{{/required}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};

        const pathParams = {
            {{#pathParams}}
            '{{baseName}}': {{#required}}{{paramName}}{{/required}}{{^required}}opts['{{paramName}}']{{/required}}{{#hasMore}},{{/hasMore}}{{/pathParams}}
        };

        const queryParams = { {{#queryParams}}
            '{{baseName}}': {{#collectionFormat}}buildCollectionParam({{#required}}{{paramName}}{{/required}}{{^required}}opts['{{paramName}}']{{/required}}, '{{collectionFormat}}'){{/collectionFormat}}{{^collectionFormat}}{{#required}}{{paramName}}{{/required}}{{^required}}opts['{{paramName}}']{{/required}}{{/collectionFormat}}{{#hasMore}},{{/hasMore}}{{/queryParams}}
        };

        const headerParams = {
            {{#headerParams}}
            '{{baseName}}': {{#required}}{{paramName}}{{/required}}{{^required}}opts['{{paramName}}']{{/required}}{{#hasMore}},{{/hasMore}}{{/headerParams}}
        };
        const formParams = { {{#formParams}}
        '{{baseName}}': {{#collectionFormat}}buildCollectionParam({{#required}}{{paramName}}{{/required}}{{^required}}opts['{{paramName}}']{{/required}}, '{{collectionFormat}}'){{/collectionFormat}}{{^collectionFormat}}{{#required}}{{paramName}}{{/required}}{{^required}}opts['{{paramName}}']{{/required}}{{/collectionFormat}}{{#hasMore}},{{/hasMore}}{{/formParams}}
        };

        const contentTypes = [{{#consumes}}'{{& mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}];
        const accepts = [{{#produces}}'{{& mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}}];

        return this.apiClient.callApi(
            '{{&path}}', '{{httpMethod}}',
            pathParams, queryParams, headerParams, formParams, postBody,
            contentTypes, accepts {{#returnType}},{{&returnType}}{{/returnType}})
    }
{{/operation}}

}
{{/operations}}
